package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CwProperty;
import com.ruoyi.system.service.ICwPropertyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * illustriousness.`cw_property`Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/system/property")
public class CwPropertyController extends BaseController
{
    @Autowired
    private ICwPropertyService cwPropertyService;

    /**
     * 查询illustriousness.`cw_property`列表
     */
    @PreAuthorize("@ss.hasPermi('system:property:list')")
    @GetMapping("/list")
    public TableDataInfo list(CwProperty cwProperty)
    {
        startPage();
        List<CwProperty> list = cwPropertyService.selectCwPropertyList(cwProperty);
        return getDataTable(list);
    }

    /**
     * 导出illustriousness.`cw_property`列表
     */
    @PreAuthorize("@ss.hasPermi('system:property:export')")
    @Log(title = "illustriousness.`cw_property`", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CwProperty cwProperty)
    {
        List<CwProperty> list = cwPropertyService.selectCwPropertyList(cwProperty);
        ExcelUtil<CwProperty> util = new ExcelUtil<CwProperty>(CwProperty.class);
        util.exportExcel(response, list, "illustriousness.`cw_property`数据");
    }

    /**
     * 获取illustriousness.`cw_property`详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:property:query')")
    @GetMapping(value = "/{pid}")
    public AjaxResult getInfo(@PathVariable("pid") Long pid)
    {
        return success(cwPropertyService.selectCwPropertyByPid(pid));
    }

    /**
     * 新增illustriousness.`cw_property`
     */
    @PreAuthorize("@ss.hasPermi('system:property:add')")
    @Log(title = "illustriousness.`cw_property`", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CwProperty cwProperty)
    {
        Long Roomtime = cwProperty.setRoomtime(cwProperty.getRoomtime());
        Long Duetime = cwProperty.setDuetime(cwProperty.getDuetime());
        return toAjax(cwPropertyService.insertCwProperty(cwProperty));
    }

    /**
     * 修改illustriousness.`cw_property`
     */
    @PreAuthorize("@ss.hasPermi('system:property:edit')")
    @Log(title = "illustriousness.`cw_property`", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CwProperty cwProperty)
    {
        Long Roomtime = cwProperty.setRoomtime(cwProperty.getRoomtime());
        Long Duetime = cwProperty.setDuetime(cwProperty.getDuetime());
        return toAjax(cwPropertyService.updateCwProperty(cwProperty));
    }

    /**
     * 删除illustriousness.`cw_property`
     */
    @PreAuthorize("@ss.hasPermi('system:property:remove')")
    @Log(title = "illustriousness.`cw_property`", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pids}")
    public AjaxResult remove(@PathVariable Long[] pids)
    {
        return toAjax(cwPropertyService.deleteCwPropertyByPids(pids));
    }
}
